#include<iostream>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
using namespace std;

int main()
{
    int* p = nullptr;
    cout << *p;

    return 0;
}

#if 0
class Solution {
public:
    vector<int> findSubstring(string s, vector<string>& words) {

        unordered_map<string, int> base_hash;
        vector<int> ret;
        int singleLen = words[0].size();
        int len = words.size();
        for (auto& a : words)
            base_hash[a]++;

        for (int i = 0; i < singleLen; i++)
        {
            unordered_map<string, int> cur_hash;
            for (int left = i, right = i, count = 0; right + singleLen <= s.size(); right += singleLen)
            {
                string look = s.substr(left, right - left + 1);
                string in = s.substr(right, singleLen);
                cur_hash[in]++;
                if (base_hash.count(in) && cur_hash[in] <= base_hash[in])count++;
                if (right - left + 1 > len * singleLen)
                {
                    string out = s.substr(left, singleLen);
                    if (base_hash.count(out) && cur_hash[out] <= base_hash[out])count--;
                    cur_hash[out]--;
                    left += singleLen;
                }
                if (count == len)
                    ret.push_back(left);
            }
        }
        return ret;
    }
};
int main()
{
    string s{ "barfoofoobarthefoobarman" };
    vector<string>words{ "bar","foo","the" };
    vector<int>nums = Solution().findSubstring(s,words);
    for (auto num : nums)
        cout << num << ' ';

    return 0;
}


//std::views
int main()
{
    unordered_map<string, int>hash1{ {"fergsg",1},{"fergs",1},{"frgsg",1} };
    unordered_map<string, int>hash2{ {"fergsg",1},{"fergs",1},{"frgsg",1} };
    for (auto [e1, e2] : zip(hash1, hash2))
    {

    }
    return 0;
}
https://leetcode.cn/problems/find-all-anagrams-in-a-string/
class Solution {
public:

    struct Com
    {
        bool operator()(vector<int>& a, vector<int>& b)
        {
            for (int i = 0; i < a.size(); i++)
                if (a[i] != b[i])
                    return false;

            return true;
        }
    };

    vector<int> findAnagrams(string s, string p) {
        Com com;
        vector<int>ret;
        string& a = p;
        string& b = s;
        int asize = a.size();
        int bsize = b.size();
        vector<int>a_hash(27);
        vector<int>b_hash(27);
        for (auto c : a)
            a_hash[c - 'a']++;
        for (int left = 0, right = 0; right < bsize; right++)
        {
            b_hash[b[right] - 'a']++;
            while (right - left + 1 > asize)
                b_hash[b[left++] - 'a']--;
            if (right - left + 1 == asize && com(b_hash, a_hash))
                ret.push_back(left);
        }
        return ret;
    }
};
class Solution {
public:
    vector<int> rearrangeBarcodes(vector<int>& barcodes) {
        int sz = barcodes.size();
        sort(barcodes.begin(), barcodes.end());
        int t = 0;
        int n = 0;
        for (int i = 0; i < sz; i++)
        {
            int _t = 1;
            int _n = barcodes[i];
            while (i < sz - 1 && _n == barcodes[i + 1])
            {
                i++;
                _t++;
            }
            n = _t > t ? _n : n;
            t = max(t, _t);
        }
        vector<int>ret;
        if (2 * t - sz == 1)
            ret.push_back(n);
        for (auto num : barcodes)
        {
            if (num == n)
                continue;
            ret.push_back(num);
            if (t--)
                ret.push_back(n);
        }

        return ret;
    }
};

class Solution {
public:
    int sz;
    vector<vector<int>> e;
    map<pair<int, int>, int> mark;
    int dfs(int i, int w, int h)
    {
        if (mark.count({ w,h }) != 0)
            return mark[{w, h}];
        int ret = 0;
        if (i >= sz)
            return 0;
        int cw = e[i][0], ch = e[i][1];
        if (cw == w || h == ch)
            ret = dfs(i + 1, w, h);
        else
        {
            if (h < ch)
                ret = 1 + dfs(i + 1, cw, ch);
            else
                ret = max(dfs(i + 1, w, h), dfs(i + 1, cw, ch));
        }
        mark[{w, h}] = ret;
        return ret;
    }
    int maxEnvelopes(vector<vector<int>>& envelopes) {
        e = envelopes;
        sort(e.begin(), e.end(), [](vector<int>a, vector<int>b)
            {
                if (a[0] != b[0])
                    return a[0] < b[0];
                else
                    return a[1] < b[1];
            });
        sz = e.size();
        return 1 + dfs(1, e[0][0], e[0][1]);
    }
};
int main()
{
    vector<vector<int>>envelopes = { {1,3},{3,5},{6,7},{6,8},{8,4}, { 9,5 } };
    cout << Solution().maxEnvelopes(envelopes) << endl;

    return 0;
}

int main()
{
    int ret = 0;
    int n = 65536;
    while(n!=1)
    {
        while (n % 2 == 0)
        {
            ret++;
            n /= 2;
            cout << n << endl;
        }
        if (n != 1)
        {
            ret++;
            n--;
            cout << n << endl;
        }
    }

    cout  << ret << endl;
	return 0;
}



#endif